<?php defined('SYSPATH') or die('No direct script access.');
 
class Model_Asays extends ORM {
	protected $_table_name = 'says';

	protected $_belongs_to = array(
		'work' => array(
			'model' => 'Aworks',
			'foreign_key' => 'work_id',
		),
		'admin' => array(
			'model' => 'Ateam',
			'foreign_key' => 'admin_id',
		),
	);

    public function params() {
        return array(
        	'model' => 'Asays',
        	'table' => 'says',
            'fields' => array(
                'work_id' => array(
                    'title' => 'Проект',
                    'name' => 'work_id',
                    'type' => 'relation',
                    'relation_params' => array(
                        'type' => 'BELONGS_TO',
                        'model' => 'Aworks',
                        'field' => 'title'
                    ),
                ),
                'admin_id' => array(
                    'title' => 'Кто сказал',
                    'name' => 'admin_id',
                    'type' => 'relation',
                    'relation_params' => array(
                        'type' => 'BELONGS_TO',
                        'model' => 'Ateam',
                        'field' => 'fio'
                    ),
                ),
                'content' => array(
                    'title' => 'Текст',
                    'name' => 'content',
                    'type' => 'tinymce',
                ),
                'content_en' => array(
                    'title' => 'Текст (en)',
                    'name' => 'content_en',
                    'type' => 'tinymce',
                ),
                'say' => array(
                    'title' => 'Сообщение',
                    'name' => 'say',
                    'type' => 'tinymce',
                ),
                'say_en' => array(
                    'title' => 'Сообщение (en)',
                    'name' => 'say_en',
                    'type' => 'tinymce',
                ),
                'image' => array(
                    'title' => 'Изображение',
                    'name' => 'image',
                    'type' => 'image',
                    'image_params' => array(
                        'handling' => 'resize',
                        'resize_type' => Image::WIDTH,
                        'width' => '620',
                        'height' => NULL,
                        'dir' => $_SERVER['DOCUMENT_ROOT'].'/static/uploads/says/',
                        'url' => URL::base().'static/uploads/says/',
                    )
                ),
            ),
            'search_indexes' => array(
                array('field' => 'content', 'title' => 'Описание'),
                array('field' => 'content_en', 'title' => 'Описание en'),
                array('field' => 'say', 'title' => 'Комментарий'),
                array('field' => 'say_en', 'title' => 'Комментарий en'),
            ),
			'main_title' => 'От разработчика',
			'waymark' => 'content'
        );
    }

}